#pragma once
#include <boost/signals2.hpp>
#include <boost/describe.hpp>
#include <SFML/System/Vector2.hpp>
#include <SFML/Graphics/ConvexShape.hpp>
#include <nice2d/predef.h>
#include <nice2d/serializer.h>

enum TileMapType {
    TileMapType_Hex = 0,
    TileMapType_Grid,
    TileMapType_MalGrid,
};

BOOST_DESCRIBE_ENUM(TileMapType, TileMapType_Hex, TileMapType_Grid, TileMapType_MalGrid)

class Tile : public sf::ConvexShape, public Serializer
{
public:
    Tile() = delete;
    Tile(uint16_t x, uint16_t y, float sideLength, TileMapType type);
    virtual ~Tile();
public:
    void setTileType(int type);
    int  getTileType()const;

    void setTileResourceId(int resourceId);
    int  getTileResourceId()const;

    void setWalkable(bool walkable);
    bool isWalkable()const;

    void setOwner(const sf::Color &color);
    sf::Color getOwner()const;

    void setSprite(SpritePointer sprite);
    SpritePointer getSprite()const;

    void setVisible(bool visible);
    bool isVisible()const;
public:
    PTree serialize() override;
    void deserialize(const PTree &node) override;
private:
    std::unique_ptr<class TileData> data;
};

class TileVisitor
{
public:
    virtual void visit(int32_t x, int32_t y, std::shared_ptr<Tile> tile) = 0;
};